<#include "/common/header.html" >
<body class=" gray-bg">
<div class="wrapper wrapper-content  animated fadeInRight">
        <div class="row">
            <div class="col-sm-12">
                <div class="ibox">
                    <div class="ibox-content">
                        <form action="" id="categoryForm" class="form-horizontal">
                           <div class="form-group">
                                <label class="col-sm-2 control-label">分类名称</label>
                                <div class="col-sm-10">
                                    <input type="text" name="name" id="name" class="form-control">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">父分类</label>
                                <div class="col-sm-10">
                                <select class="form-control m-b" name="parentId">
                               		<option value="0">请选择</option>
                               		<#list cateList as cate>
                               			<option value="${cate.id}">${cate.name}</option>
                               		</#list>
                            	</select>
                                </div>
                            </div>
                            
                            <div class="form-group">
                                <label class="col-sm-2 control-label">分类banner图</label>
                                <div class="col-sm-10">
                                <img alt="" src="" id="bannerUrlFileImg">
                               <input type="file" id="bannerUrlFile"  name="file" class="form-control">
                               <input type="hidden" id="bannerUrl" name="bannerUrl" value="">
                                </div>
                            </div>
                             <div class="form-group">
                                <label class="col-sm-2 control-label">分类图标</label>
                                <div class="col-sm-10">
	                               <img alt="" src="" id="iconUrlFileImg">
	                               <input type="file" id="iconUrlFile" name="file"  class="form-control">
	                               <input type="hidden" id="iconUrl" name="iconUrl" value="">
                                </div>
                            </div>
                             <div class="form-group">
                                <div class="col-sm-4 col-sm-offset-2">
                                    <button class="btn btn-primary" type="submit">保存内容</button>
                                    <button class="btn btn-warning" type="button" onclick="history.back()">返回列表</button>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <#include "/common/footer.html" >
	<script type="text/javascript">
	$(function(){
		
		$("#bannerUrlFile").change(function(){
			$.ajaxFileUpload({
				url:"/upload",
				type:"POST",
				fileElementId:"bannerUrlFile",
				dataType:"json",
				success:function(data){
					//
					$("#bannerUrl").val(data.fileId);
					$("#bannerUrlFileImg").attr("src","/view/" +data.fileId);
				},
				error:function(data){
					console.error("upload file error");
				}
			});
		})
	
		$("#iconUrlFile").change(function(){
			$.ajaxFileUpload({
				url:"/upload",
				type:"POST",
				fileElementId:"iconUrlFile",
				dataType:"json",
				success:function(data){
					console.log(data)
					//
					$("#iconUrl").val(data.fileId);
					$("#iconUrlFileImg").attr("src","/view/" +data.fileId);
				},
				error:function(data){
					console.log(data)
					console.error("upload file error");
				}
			});
		})
		
		$("#categoryForm").submit(function(){
			
			$.ajax({
				url:"/sys/cates/add",
				type:"POST",
				data:$("#categoryForm").serialize(),
				success:function(data){
					wxLayer.alert(data.message,function(){
						if(data.status)
							location.href = "/sys/cates/list";
					});
				},
				error:function(){
					
				}
			})
			
			return false;
		})
		
	});
	
	</script>
</body>


<!-- Mirrored from www.zi-han.net/theme/hplus/ by HTTrack Website Copier/3.x [XR&CO'2014], Wed, 20 Jan 2016 14:17:11 GMT -->
</html>
